<?php

class Shop_Widgets_Breadcrumb_Widget extends Tomato_Widget
{
    protected function _prepareShow()
    {
        $request = Zend_Controller_Front::getInstance()->getRequest();
        $lang = $request->getParam('lang');

        $category_id = ($request->getParam('cat'))?$request->getParam('cat'):$request->getParam('category_id');

        /**
        * Get connection to database
        **/
        $conn = Tomato_Db_Connection::factory()->getMasterConnection();

        /**
         * Category models access to data
         */
        $categoryDao = Tomato_Model_Dao_Factory::getInstance()->setModule('shop')->getCategoryDao();
        $categoryDao->setDbConnection($conn);
        $categoryDao->setLang($lang);

        $categories = null;
        if($category_id){
            $categories = $categoryDao->getParents($category_id);
        }
        $this->_view->assign('categories', $categories);
    }
    protected function _prepareConfig()
    {

    }
}
